﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using Newtonsoft.Json;

namespace Finance.UI.Web
{
    public class CamelCaseStringWriter : JsonTextWriter
    {
        public CamelCaseStringWriter(TextWriter textWriter)
            : base(textWriter)
        {

        }

        public override void WritePropertyName(string name)
        {
            base.WritePropertyName(camelCase(name));
        }

        private string camelCase(string name)
        {
            if (!string.IsNullOrWhiteSpace(name))
            {
                return name.Substring(0, 1).ToLower() + name.Substring(1);
            }
            return name;
        }
    }
}